using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Sudoku.Menu
{
	public class NumberButton : Button
	{
		public byte Value;
		private Rectangle textCoord;
		private Color numberColor;

		private Texture2D selBg;
		private Color selColor;
		private Rectangle selRect;
		
		public NumberButton(Game game, Rectangle rect, byte value) : base(game, rect)
		{
			Value = value;
		}

		public override void Initialize()
		{
			textCoord = new Rectangle(Value * 50, 0, 50, 50);
			numberColor = new Color(5, 77, 110);

			selBg = textureService.Texture("WhiteFill");
			selColor = Color.Pink;
			selColor.A = 100;
			selRect = new Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 2);

			base.Initialize();
		}

		public override void Draw(GameTime gameTime)
		{
			if (state == ButtonState.DOWN)
			{
				spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.NonPremultiplied);
					spriteBatch.Draw(selBg, selRect, selColor);
				spriteBatch.End();
			}

			spriteBatch.Begin();

			spriteBatch.Draw(Texture, rect, textCoord, (!Enabled) ? disabledColor : numberColor);
			
			spriteBatch.End();
		}

	}
}
